package com.iye.puretennis.custom;

import android.content.Context;
import android.graphics.Typeface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.iye.puretennis.helper.Constant;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: jing wu
 * Date: 2014/12/1
 * Time: 10:33
 */
public class IdolDropdownAdapter<Idol> extends ArrayAdapter {

    private Context mainContext;

    public IdolDropdownAdapter(Context context, int resource, List<Idol> idols) {

        super(context, resource, idols);
        mainContext = context;

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View view = super.getView(position, convertView, parent);

        setTextStyle(view);

        return view;
    }

    private void setTextStyle(View convertView) {
        CustomApplication application = (CustomApplication) mainContext.getApplicationContext();


        if (convertView instanceof TextView) {
            TextView currentTextView = (TextView) convertView;
            currentTextView.setTypeface(application.getHuaWenHuPo());
            currentTextView.setTextSize(28.0f);
        }
    }

    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {

        View dropDownView = super.getDropDownView(position, convertView, parent);

        setTextStyle(dropDownView);

        return dropDownView;
    }

}
